﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace Nivlag
{
    /// <summary>
    /// This class contains methods and fields to represent a library.
    /// The concept here is driven by an interest in figuring out the size of docs in a library.
    /// </summary>
    public class ListAnalysis
    {

        private WebListUrlParameters myListParams;

        public WebListUrlParameters MyListParams
        {
            get { return myListParams; }
            set { myListParams = value; }
        }

        public ListAnalysis(WebListUrlParameters ListParams)
        {
            myListParams = ListParams;

        }

        public ListAnalysis()
        {
        }

        public List<string> ListProperties;

        public List<string> AnalyzeLibrary()
        {

            List<string> LibraryProperties;

            LibraryProperties = new List<string>();

            using (SPSite siteCollection = new SPSite(myListParams.WebUrl))
            {
                using (SPWeb aWeb = siteCollection.AllWebs[myListParams.MyWebRelativeUrl])
                {

                    SPList theList = aWeb.Lists[myListParams.ListIdAsGuid];

                    LibraryProperties.Add("Debug:");
                    LibraryProperties.Add("Got the web!");

                    LibraryProperties.Add("Item count:");
                    LibraryProperties.Add(theList.ItemCount.ToString());

                    
                    return LibraryProperties;

                } // using SPWeb
            } // using SPSite

            LibraryProperties.Add("Testfield");
            LibraryProperties.Add("Could not find the site.");

            return null;

        } // AnalyzeLibrary

    } //  LibraryAnalysis
}
